﻿using System;
using System.Text;
using IAM.Interface.Model.Interface;

namespace IAM.Interface.Model
{
    /// <summary>
    /// 组织机构信息
    /// 包括机构基本信息和主管人员信息
    /// </summary>
    public class OrganizeInfo : AbstractConvertObject, IConvertXml
    {
        #region 属性
        private OrganizeBaseInfo _organizebaseinfo;
        private AccountInfo _director;
        /// <summary>
        /// 组织机构基本信息
        /// </summary>
        public OrganizeBaseInfo OrganizeBaseInfo
        {
            get
            {
                return _organizebaseinfo;
            }
            set
            {
                _organizebaseinfo = value;
            }
        }
        /// <summary>
        /// 机构主管信息
        /// </summary>
        public AccountInfo Director
        {
            get
            {
                return _director;
            }
            set
            {
                _director = value;
            }
        }
        #endregion
        #region IConvertXml

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append(this.OrganizeBaseInfo.XML);
                _xml.Append("<Director>");
                _xml.Append(this.Director.XML);
                _xml.Append("</Director>");
                return _xml.ToString();
            }


        }

        public string XMLFinis
        {
            get
            {
                return "";
            }
        }
        public string XML
        {
            get
            {
                return XMLBoday + XMLFinis;
            }
        }
        #endregion
        #region AbstractConvertObject
        public override object ConvertToObject()
        {
            this.OrganizeBaseInfo = new OrganizeBaseInfo();
            this.OrganizeBaseInfo.CurrentXmlNode = this.CurrentXmlNode;
            this.OrganizeBaseInfo = (OrganizeBaseInfo)this.OrganizeBaseInfo.ConvertToObject();

            this.Director = new AccountInfo();
            this.Director.CurrentXmlNode = this.CurrentXmlNode.SelectSingleNode("Director/AccountInfo");
            this.Director = (AccountInfo)this.Director.ConvertToObject();

            return this;
        }
        #endregion
    }
}
